package com.wj.facedetect.bean.common;

public enum CodeEnum {
    //服务器定义
    codeFailed(0, "请求失败"),
    codeSuccess(1, "请求成功"),
    //App自定义
    dataInnerMismatch(-0x1001, "内层数据格式不匹配"),
    dataOutMismatch(-0x1002, "外层数据格式不匹配"),
    dataEmpty(-0x1003, "数据为空");
    private int code;
    private String message;

    CodeEnum(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public static CodeEnum getEnum(int code) {
        CodeEnum result = null;
        for (CodeEnum codeEnum : values()) {
            if (codeEnum.code == code) {
                result = codeEnum;
                break;
            }
        }
        return result;
    }

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    @Override
    public String toString() {
        return "CodeEnum{" +
                "code=" + code +
                ", message='" + message + '\'' +
                '}';
    }
}
